import { workflowHttpRequest as request } from '@/utils/http';
import type { WorkflowDefinition } from './type';

// Api地址
enum Api {
  DEFAULT_URL = 'api/workflow'
}

// 创建工作流定义
export const createAsync = (input: WorkflowDefinition) =>
  request.post<WorkflowDefinition>(Api.DEFAULT_URL, input);

// 创建工作流定义
export const updateAsync = (id: string, version: string, input: WorkflowDefinition) =>
  request.put<WorkflowDefinition>(`${Api.DEFAULT_URL}/${id}?version=${version}`, input);

// 获取工作流定义
export const getAsync = (id: string, version: string) => request.get<WorkflowDefinition>(`${Api.DEFAULT_URL}/${id}?version=${version}`);

// 获取工作流操作步骤
export const getStepBodysAsync = () => request.get<any>(Api.DEFAULT_URL + '/all-step');

// 获取所有分组
export const getAllGroupAsync = () => request.get<Array<string>>(Api.DEFAULT_URL + '/all-group');